<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
$gType = chkGametype($gametype);
switch ($gType)
{
    case 0 :
        $ui = new UI();
        break;
    default :
        include_once( "class_3d/CheckMode_3d.php" );
        $chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
        $chk->checkShow3dPage();
        unset($chk);
        $ui = new UI_3D();
        $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>" . ( "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>" );
        $ui->set("jslink", $jslink);
        $ui->header();
        break;
}
$tpl = new Template2();
$reat0_open = $conf->get("reat0_open");
if (isset($_POST['id']))
{
    if ($curruser['acl'] == 5)
    {
        include_once( "class/class.findmember_chk.php" );
        $fdc = new findmember_chk();
        $fdc_val = $fdc->search_chk($_POST['id']);
        if ($fdc_val)
        {
            $id = getvar("id");
            if ($id == "")
            {
                $ui->showErrorPage("请输入会员帐号！");
                exit();
            }
            $rs = getdb("select * from k_user where account='" . $id . "' and acl<5");
            if ($rs->eof)
            {
                $ui->showErrorPage("错误的会员帐号！");
                exit();
            }
            echo " &nbsp; <a href=\"javascript:history.back()\">[回上一页]</a>";
            echo "<table border='1' cellpadding='3' cellspacing='0' width='800'>";
            echo "<tr class=td0 align=center><td width=\"50\">管理层<td width=\"30\">ID<td width=\"50\">帐号<td width=\"50\">名称";
            echo "<td nowrap>六合信用额度";
            //if ($g_init_mode_6h && $reat0_open)
            //{
            //    echo "<td nowrap>特码减倍";
            //}
            if ($g_init_mode_3d)
            {
                echo "<td nowrap class=c3>福体彩信用额度<td nowrap class=c4>时时信用额度";
            }
            echo "<td nowrap>最後登入日<td nowrap>最後登入IP";
            $acl = $rs->f['acl'];
            if ($acl < 3 && 0 < $acl)
            {
                $showPerFlag = true;
            }
            else
            {
                $showPerFlag = false;
            }
            if ($acl < 0 && 0 - 6 < $acl)
            {
                $tempAcl = $acl * ( 0 - 1 );
                $tempUPAcl = get_user($rs->f['prev_id'], $gametype);
                echo "<tr class=td2><td nowrap class=td5 align=center>" . $aclname[$tempAcl] . "子帐号<br />归属:" . $tempUPAcl['account'] . "<td nowrap>" . $rs->f['id'] . "<td nowrap>" . $rs->f['account'] . "<td nowrap>" . $rs->f['name'];
                echo "<td nowrap align=right> -- ";
                if ($g_init_mode_6h && $reat0_open)
                {
                    echo "<td nowrap align=right> -- ";
                }
                if ($g_init_mode_3d)
                {
                    echo "<td nowrap align=right> -- <td nowrap align=right> -- ";
                }
                echo "<td nowrap>" . ( $rs->f['lastlogdt'] == "" ? "" : date("Y-m-d", $rs->f['lastlogdt']) ) . "<td nowrap>" . $rs->f['lastlogip'];
            }
            switch ($acl)
            {
                case 1 :
                    echo "<tr class=td2><td nowrap class=td5 align=center>会员<td nowrap>" . $rs->f['id'] . "<td nowrap><a href='?op=agent&fp=member&cmd=edit&id=" . $rs->f['id'] . "&gametype={$gametype}'>" . $id . "</a><td nowrap>" . $rs->f['name'];
                    echo "<td nowrap align=right>" . $rs->f['amount'];
                    if ($g_init_mode_6h && $reat0_open)
                    {
                        echo "<td nowrap align=right>" . $rs->f['rate0'];
                    }
                    if ($g_init_mode_3d)
                    {
                        echo "<td nowrap align=right>" . $rs->f['amount_3d'] . "<td nowrap align=right>" . $rs->f['amount_3s1'];
                    }
                    echo "<td nowrap>" . ( $rs->f['lastlogdt'] == "" ? "" : date("Y-m-d", $rs->f['lastlogdt']) ) . "<td nowrap>" . $rs->f['lastlogip'];
                    $u2 = get_user($rs->f['prev_id'], $gametype);
                case 2 :
                    $u2 = isset($u2) ? $u2 : $rs->f;
                    echo "<tr class=td2><td nowrap class=td5 align=center>代理商<td nowrap>" . $u2['id'] . "<td nowrap><a href='?op=genagent&fp=agent&cmd=edit&id=" . $u2['id'] . "&gametype={$gametype}'>" . $u2['account'] . "</a><td nowrap>" . $u2['name'];
                    echo "<td nowrap align=right>" . $u2['amount'];
                    if ($g_init_mode_6h && $reat0_open)
                    {
                        echo "<td nowrap align=right>" . $u2['rate0'];
                    }
                    if ($g_init_mode_3d)
                    {
                        echo "<td nowrap align=right>" . $u2['amount_3d'] . "<td nowrap align=right>" . $u2['amount_3s1'];
                    }
                    echo "<td nowrap>" . ( $u2['lastlogdt'] == "" ? "" : date("Y-m-d", $u2['lastlogdt']) ) . "<td nowrap>" . $u2['lastlogip'];
                    $u3 = get_user($u2['prev_id'], $gametype);
                case 3 :
                    $u3 = isset($u3) ? $u3 : $rs->f;
                    echo "<tr class=td2><td nowrap class=td5 align=center>总代理<td nowrap>" . $u3['id'] . "<td nowrap><a href='?op=shareowner&fp=genagent&cmd=edit&id=" . $u3['id'] . "&gametype={$gametype}'>" . $u3['account'] . "</a><td nowrap>" . $u3['name'];
                    echo "<td nowrap align=right>" . $u3['amount'];
                    if ($g_init_mode_6h && $reat0_open)
                    {
                        echo "<td nowrap align=right>" . $u3['rate0'];
                    }
                    if ($g_init_mode_3d)
                    {
                        echo "<td nowrap align=right>" . $u3['amount_3d'] . "<td nowrap align=right>" . $u3['amount_3s1'];
                    }
                    echo "<td nowrap>" . ( $u3['lastlogdt'] == "" ? "" : date("Y-m-d", $u3['lastlogdt']) ) . "<td nowrap>" . $u3['lastlogip'];
                    $u4 = get_user($u3['prev_id'], $gametype);
                    break;
                case 4 :
                    $u4 = isset($u4) ? $u4 : $rs->f;
                    $u5 = get_user($u4['prev_id'], $gametype);
                    echo "<tr class=td2><td nowrap class=td5 align=center>股东<td nowrap>" . $u4['id'] . "<td nowrap><a href='?op=subsidary&fp=shareowner&cmd=edit&id=" . $u4['id'] . "&gametype={$gametype}'>" . $u4['account'] . "</a><td nowrap>" . $u4['name'];
                    echo "<td nowrap align=right>" . $u4['amount'];
                    if ($g_init_mode_6h && $reat0_open)
                    {
                        echo "<td nowrap align=right>" . $u4['rate0'];
                    }
                    if ($g_init_mode_3d)
                    {
                        echo "<td nowrap align=right>" . $u4['amount_3d'] . "<td nowrap align=right>" . $u4['amount_3s1'];
                    }
                    echo "<td nowrap>" . ( $u4['lastlogdt'] == "" ? "" : date("Y-m-d", $u4['lastlogdt']) ) . "<td nowrap>" . $u4['lastlogip'];
                    echo "<tr class=td2><td nowrap class=td5 align=center>大股东<td nowrap>" . $u5['id'] . "<td nowrap>" . $u5['account'] . "<td nowrap>" . $u5['name'];
                    echo "<td nowrap align=right>" . $u5['amount'];
                    if ($g_init_mode_6h && $reat0_open)
                    {
                        echo "<td nowrap align=right>" . $u5['rate0'];
                    }
                    if ($g_init_mode_3d)
                    {
                        echo "<td nowrap align=right>" . $u5['amount_3d'] . "<td nowrap align=right>" . $u5['amount_3s1'];
                    }
                    echo "<td nowrap>" . ( $u5['lastlogdt'] == "" ? "" : date("Y-m-d", $u5['lastlogdt']) ) . "<td nowrap>" . $u5['lastlogip'];
                    break;
            }
            echo "</table>";
            if ($showPerFlag)
            {
                $uStrArr = array("<tr class=td2><td nowrap class=td5 align=center>代理<td nowrap>" . $u2['id'] . "<td nowrap>" . $u2['account'] . "<td nowrap>" . $u2['name'], "<tr class=td2><td nowrap class=td5 align=center>总代理<td nowrap>" . $u3['id'] . "<td nowrap>" . $u3['account'] . "<td nowrap>" . $u3['name'], "<tr class=td2><td nowrap class=td5 align=center>股东<td nowrap>" . $u4['id'] . "<td nowrap>" . $u4['account'] . "<td nowrap>" . $u4['name'], "<tr class=td2><td nowrap class=td5 align=center>大股东<td nowrap>" . $u5['id'] . "<td nowrap>" . $u5['account'] . "<td nowrap>" . $u5['name'], "<tr class=td2><td nowrap class=td5 align=center>公司<td nowrap align=center>--<td nowrap align=center>--<td nowrap align=center>--");
                echo "<br /><table border='1' cellpadding='3' cellspacing='0' width='800'>";
                echo "<tr class=td1><td colspan=13 width=\"100%\" align=center>占 成 列 表";
                echo "<tr class=td0><td width=\"50\">管理层<td width=\"30\">ID<td width=\"50\">帐号<td width=\"50\">名称";
                if ($g_init_mode_6h && $g_menu_enabled[0])
                {
                    echo "<td nowrap class=paper6h>六合彩";
                    $mpercent = $u2['mpercent'];
                    $percent2 = $u2['percent0'];
                    $percent3 = min($u3['percent1'], $u4['mpercent'] - $mpercent - $percent2);
                    $percent4 = min($u4['percent1'], $u5['mpercent'] - $mpercent - $percent2 - $percent3);
                    $upercent = 100 - $mpercent - $percent2 - $percent3 - $percent4;
                    $uStrArr .= 0;
                    $uStrArr .= 1;
                    $uStrArr .= 2;
                    $uStrArr .= 3;
                    $uStrArr .= 4;
                }
                if ($g_init_mode_3d)
                {
                    foreach ($g_gametype_3d as $i => $val)
                    {
                        if ($g_menu_enabled[$i] && $i)
                        {
                            $tbl = $g_gametype_3d[$i]['en'];
                            $tblName = $g_gametype_3d[$i]['ch'];
                            echo "<td nowrap class=paper" . $tbl . ">" . $tblName;
                            $u2 = get_user($rs->f['prev_id'], $i);
                            $u3 = get_user($u2['prev_id'], $i);
                            $u4 = get_user($u3['prev_id'], $i);
                            $u5 = get_user($u4['prev_id'], $i);
                            $mpercent = $u2['mpercent'];
                            $percent2 = $u2['percent0'];
                            $percent3 = min($u3['percent1'], $u4['mpercent'] - $mpercent - $percent2);
                            $percent4 = min($u4['percent1'], $u5['mpercent'] - $mpercent - $percent2 - $percent3);
                            $upercent = 100 - $mpercent - $percent2 - $percent3 - $percent4;
                            $uStrArr .= 0;
                            $uStrArr .= 1;
                            $uStrArr .= 2;
                            $uStrArr .= 3;
                            $uStrArr .= 4;
                        }
                    }
                }
                foreach ($uStrArr as $val)
                {
                    echo $val;
                }
                echo "</table>";
            }
        }
    }
}
else
{
    echo "<font color=red><b>会员搜寻</b></font> (可搜寻层次为：会员～股东, 搜寻会员或代理帐号时，可显示管理层层占成)<br>";
    echo "<form action=\"op.php?op=admin&fp=findmember&gametype={$gametype}\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
    echo "请输入会员帐号：<input name='id' size='20'>";
    echo "&#12288;<input type='submit' name='submit' value='确 定'>";
    echo "</form>";
}
?>